<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>

<tiles:insertTemplate template="/templates/list.jsp">
	<tiles:putAttribute name="pageTitle" value="Manage hosts" />
	<tiles:putAttribute name="rightIcon">
		<a class="lnk" href="<s:url namespace="/admin" action="addEditHost"/>" title="add host">
			<img src="<s:url value="/img/add-24.png"/>" /><sup>Add new host</sup>
		</a>
	</tiles:putAttribute>
	<tiles:putAttribute name="grid">
		<s:actionerror/>
		<table class="grid" width="100%">
			<tr>
				<th>Host Name</th>
				<th>&nbsp;</th>
				<th>&nbsp;</th>
			</tr>
			<s:iterator value="hosts" status="stat" var="host">
				<s:url id="edit" namespace="/admin" action="addEditHost">
					<s:param name="id" value="entity.id" />
				</s:url>
				<s:url id="del" namespace="/admin" action="deleteHost">
					<s:param name="id" value="entity.id" />
				</s:url>

				<s:if test="#stat.odd">
					<tr class="odd">
				</s:if>
				<s:else>
					<tr class="even">
				</s:else>
					<td><s:property value="entity.name" /></td>
					<td>
						<s:if test="refCount == 0">
							This host is not monitored
						</s:if>
						<s:else>
							This host is not monitored by <s:property value="refCount" /> instance(s)
						</s:else>
					</td>
					<td class="cmd"><s:a href="%{#edit}" title="edit host"><img src="<s:url value="/img/edit-24.png"/>" /></s:a>
					<s:if test="canDelete">
						<s:a href="#" title="delete host" onclick="confirmDelete('%{#del}', '%{entity.name}');"><img src="<s:url value="/img/del-24.png"/>" /></s:a>
					</s:if>
					<s:else>
						<img title="could not delete this host due to dependency" src="<s:url value="/img/del-gs-24.png"/>" />
					</s:else>
				</td></tr>
			</s:iterator>
		</table>
		
		
		<div id="confirmDelete">
			Would you like deleting host '<span id="nameToDelete"></span>' ?
		</div>
	</tiles:putAttribute>
</tiles:insertTemplate>
